import 'package:flutter/material.dart';
import 'package:net/core/hi_base_tab_state.dart';
import 'package:net/http/dao/ranking_dao.dart';
import 'package:net/model/rank_mo.dart';
import 'package:net/model/video_model.dart';
import 'package:net/widget/video_large_card.dart';

class RankingTabPage extends StatefulWidget {
  final String sort;
  RankingTabPage({Key key, this.sort}) : super(key: key);

  @override
  _RankingTabPageState createState() => _RankingTabPageState();
}

class _RankingTabPageState
    extends HBaseTabState<RankingMo, VideoModel, RankingTabPage> {
  @override
  get contentChild => Container(
          child: ListView.builder(
        controller: scrollController,
        physics: AlwaysScrollableScrollPhysics(), //保证内容没有充满整个屏幕事也可以下拉刷新
        padding: EdgeInsets.only(top: 10),
        itemCount: dataList.length,
        itemBuilder: (context, int index) =>
            VideoLargeCard(videoModel: dataList[index]),
      ));

  @override
  Future<RankingMo> getData(int pageIndex) async {
    RankingMo result =
        await RankingDao.get(widget.sort, pageIndex: pageIndex, pageSize: 10);
    return result;
  }

  @override
  List<VideoModel> parseList(RankingMo resulet) {
    return resulet.list;
  }

  @override
  bool get wantKeepAlive => true;
}
